-expanded = false unless local_assigns.has_key?(:expanded)

-systems.each do |system|
  %li.system-node
    .row-fluid
      .span12
        %a.system-slot.regulationslot.toggle.span12.collapsed{ :'data-toggle' => 'collapse', :'data-target' => "#content_system_#{system.id}" }
          /-if !system.description.blank?
          .expander{ :class => expanded && 'in' }
          %span.prefix=system.slug
          =system.title || system.description
        -#.controllist.attached.span3{ :class => "statusblue" }
          dunno
      .row-fluid-slotcontent
        .span12
          -#.collapse{ :id => "content_#{system.id}" }
          =system.description
    %ul.collapse{ :class => expanded && 'in', :id => "content_system_#{system.id}" }
      =walk_slug_tree(Program.slugtree(system.controls)) do |item, step|
        .row-fluid
          .span12
            %a.regulationslot.toggle.span9.collapsed{ :'data-toggle' => 'collapse', :'data-target' => "#content_item_#{item.id}" }
              -if !item.description.blank?
                .expander
              %span.prefix=item.slug
              =item.title || item.description
            .controllist.attached.span3{ :class => "statusblue" }
              -controls = item.implementing_controls
              -if !controls.empty?
                %ul.spannomargin{ :title => controls.map(&:slug).join(", ") }
                  %li
                    %strong #{controls.size}:
                  -controls.each do |control|
                    %li=control.slug
              -else
                .controls
                  %strong 0
          .row-fluid-slotcontent
            .span9
              .collapse{ :id => "content_item_#{item.id}" }
                =item.description
      -subsystems = system.id == 3 ? [System.find(2), System.find(4)] : []
      -if subsystems.count > 0
        %li
          %ul
            =render :partial => 'sub_system_branch', :locals => { :systems => subsystems }
